<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Auth;


// 点赞表
class Vote extends Model
{

    protected $guarded = [];


    public function voted()
    {
        return $this->morphTo();
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }


    protected static function boot()
    {
        parent::boot();
        if (Auth::guest()) return;




//        static::created(function ($vote){
//            $vote_type = $vote->voted;
//            $user = $vote_type->user;
//            $user->setVotedMessage($vote);
//        });


    }




}
